﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Lwm.x10c.Assemble
{
    public class ArgsAssembler
    {
        private Assembler a;

        public ArgsAssembler(Assembler a)
        {
            this.a = a;
        }

        public ArgsAssembler Reg(Reg reg)
        {
            int code = (int)reg;
            return a.Arg(code);
        }

        public ArgsAssembler RegInd(Reg reg)
        {
            int code = (int)reg + 0x08;
            return a.Arg(code);
        }

        public ArgsAssembler RegOff(Reg reg, ushort offset)
        {
            int code = (int)reg + 0x10;
            return a.Arg(code, offset);
        }

        public ArgsAssembler Pop()
        {
            return a.Arg(0x18);
        }

        public ArgsAssembler Peek()
        {
            return a.Arg(0x19);
        }

        public ArgsAssembler Push()
        {
            return a.Arg(0x1a);
        }

        public ArgsAssembler SP()
        {
            return a.Arg(0x1b);
        }

        public ArgsAssembler PC()
        {
            return a.Arg(0x1c);
        }

        public ArgsAssembler O()
        {
            return a.Arg(0x1d);
        }

        public ArgsAssembler Mem(ushort addr)
        {
            return a.Arg(0x1e, addr);
        }

        public ArgsAssembler Literal(ushort value)
        {
            if (value <= 0x1f)
            {
                int code = value + 0x20;
                return a.Arg(code);
            }
            else
            {
                return a.Arg(0x1f, value);
            }
        }
    }
}
